package org.coding.springbootdemocommandline;

import org.coding.springbootdemocommandline.factorybean.AppUserService;
import org.coding.springbootdemocommandline.propertysource.LoadPropertiesData;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.context.WebServerInitializedEvent;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.context.annotation.ImportResource;
import org.springframework.context.event.EventListener;

import javax.annotation.Resource;

@SpringBootApplication
public class SpringbootDemoCommandlineApplication {
	private Logger logger = LoggerFactory.getLogger(this.getClass());
	public static void main(String[] args) {
		ConfigurableApplicationContext context = SpringApplication.run(SpringbootDemoCommandlineApplication.class, args);
		AppUserService appUserService = context.getBean(AppUserService.class);
		appUserService.sayHello();
	}

	@Resource
	private LoadPropertiesData propertiesData;

	@EventListener(WebServerInitializedEvent.class)
	public void onWebServerReady(WebServerInitializedEvent event){
		logger.info("当前webserver实现类为:{}",event.getWebServer().getClass().getName());
		System.out.println(propertiesData.getName());
	}

}
